package com.atguigu.educms.controller;


import com.atguigu.common.R;
import com.atguigu.educms.entity.QaAnswer;
import com.atguigu.educms.entity.QaSecondAnswer;
import com.atguigu.educms.service.QaQuestionService;
import com.atguigu.educms.service.QaSecondAnswerService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Panghl
 * @since 2021-03-14
 */
@RestController
@RequestMapping("/educms/qa-second-answer")
public class QaSecondAnswerController {

    @Autowired
    private QaSecondAnswerService answerService;

    @ApiOperation(value = "二级回帖")
    @PostMapping("/2Reply")
    public R reply(@RequestBody(required = false) QaSecondAnswer answer) {
        try {
            if (!StringUtils.isEmpty(answer)) {
                answerService.save(answer);
                return R.ok();
            }
            return R.error();
        } catch (Exception e) {
            return R.error();
        }
    }
}
